package observer;

import javax.swing.JButton;

public class Frame extends javax.swing.JFrame
{
	//private Senzor senzor;
	private ValoareCurenta jTextField1;
	private ValoareCurentaBara canvas1;
	private ValoareCurentaHistograma canvas2;
	private ValoareCurentaClock canvas3;
	private JButton jButton1;
	
	Senzor senzor = new Senzor();
	//Creates new form frame
	public Frame()
	{
		initComponents();
		senzor.addObserver((Observer)jTextField1);
		/*Adauga observer pt jTextField1*/
		senzor.addObserver((Observer)canvas1);
		/*Adauga observer pt canvas1*/
		senzor.addObserver((Observer)canvas2);
		/*Adauga observer pt canvas2*/
		senzor.addObserver((Observer)canvas3);
		/*Adauga observer pt canvas3*/
		
	}
	private void initComponents()
	{
		canvas1=new ValoareCurentaBara();
		canvas2=new ValoareCurentaHistograma();
		jTextField1=new ValoareCurenta();
		jButton1=new javax.swing.JButton();
		canvas3=new ValoareCurentaClock();
		setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE);
		jButton1.setText("Genereaza");
		jButton1.addActionListener(new java.awt.event. ActionListener(){
			public void actionPerformed(java.awt.event.ActionEvent evt)
			{
				jButton1ActionPerformed(evt);
			}
		});


		javax.swing.GroupLayout layout=new javax.swing.GroupLayout(getContentPane());
		getContentPane().setLayout(layout);
		layout.setHorizontalGroup(layout.
		createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
		.addGroup(
		javax.swing.GroupLayout.Alignment.TRAILING,layout.createSequentialGroup()
		.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
		.addGroup(layout.createSequentialGroup().addContainerGap()
		.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
		.addComponent(canvas1,javax.swing.GroupLayout.DEFAULT_SIZE,
			javax.swing.GroupLayout.DEFAULT_SIZE,Short.MAX_VALUE)
		 .addComponent(canvas3,javax.swing.GroupLayout.DEFAULT_SIZE,
		javax.swing.GroupLayout.DEFAULT_SIZE,Short.MAX_VALUE))
		.addGap(45,45,45))
		.addGroup(layout.createSequentialGroup()
		.addGap(38,38,38).addComponent(jTextField1,
		javax.swing.GroupLayout.PREFERRED_SIZE,163,
		javax.swing.GroupLayout.PREFERRED_SIZE).addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)))
		.addComponent(canvas2,javax.swing.GroupLayout.PREFERRED_SIZE,249,
		javax.swing.GroupLayout.PREFERRED_SIZE).addContainerGap(56,Short.MAX_VALUE))
	.addGroup(layout.createSequentialGroup().addGap(69,69,69)
	.addComponent(jButton1).addContainerGap(362,Short.MAX_VALUE)));
		
		layout.setVerticalGroup(layout.createParallelGroup(
		javax.swing.GroupLayout.Alignment.LEADING).addGroup(
		layout.createSequentialGroup().addContainerGap()
		.addGroup(layout.createParallelGroup(
		javax.swing.GroupLayout.Alignment.LEADING,false)
		.addComponent(canvas2,0,0,Short.MAX_VALUE)
		.addComponent(canvas1,javax.swing.GroupLayout.DEFAULT_SIZE,132,Short.MAX_VALUE))
		.addGap(37,37,37)
		.addComponent(canvas3,javax.swing.GroupLayout.PREFERRED_SIZE,121,javax.swing.GroupLayout.PREFERRED_SIZE)
		.addGap(32,32,32)
		.addComponent(jButton1)
		.addGap(18,18,18)
		.addComponent(jTextField1,javax.swing.GroupLayout.PREFERRED_SIZE,29,javax.swing.GroupLayout.PREFERRED_SIZE)
		.addGap(75,75,75)));
		pack();//</editor-fold>//GEN-END:initComponents
		
	}
	private void jButton1ActionPerformed(java.awt.event.ActionEvent evt)
	{
		senzor.generare();
	}//GEN_LAST: event_jButton1ActionPerformed

	public static void main(String args[])
	{
		java.awt.EventQueue.invokeLater(new Runnable()
		{
			public void run()
			{
				new Frame().setVisible(true);
			}
		});
		
	}
	

}
